package com.detrum.sportcamera.utils;

/**
 * Created by chenlei on 2017/2/20.
 */

public class NetUtils {

    /**
     * 将字符串ip转换为byte数组
     * @param ip
     * @return
     */
    public static byte[] getIpBytes(String ip){
        if(ip==null){
            return null;
        }
        String[]strs = ip.split("\\.",6);
        byte[] data = new byte[strs.length];
        for (int i = 0; i < strs.length; i++) {
            data[i] = (byte) (Integer.parseInt(strs[i])&0xff);
        }
        return data;
    }
}
